export default {
	data() {
		return {
			secResLists: [],
			secInfoPageObj: {
				page_size: 20,
				page: 1,
				count: -1,
			},
			secPageLoading: true,
			isShowSecPageLoadedTxt: false,
		}
	},

	async onLoad(option) {
		await this.GetSecResLists();
	},
	async onReachBottom() {
		if(this.secPageLoading) {
			await (this.secPageLoading = false);
			await this.GetSecResLists();
			await (this.secPageLoading = true);
		}
	},
	methods: {
		async secScrolltolower() {
			if(this.secPageLoading) {
				await (this.secPageLoading = false);
				await this.GetSecResLists();
				await (this.secPageLoading = true);
			}
		},
		secPagingInitFun(page_size = 20) {
			this.secResLists = [];
			this.secInfoPageObj.page = 1;
			this.secInfoPageObj.count = -1;
			this.secInfoPageObj.page_size = page_size;
		},
		secPagingAddFun() {
			this.secInfoPageObj.page++;
		},
		secPagingCountFun(count) {
			this.secInfoPageObj.count = count;
		},
		secPagingListFun(secResLists) {
			this.secResLists = [...this.secResLists, ...secResLists];
		},
		secPagingMoreFun() {
			const {secInfoPageObj, secResLists} = this;
			if (secInfoPageObj.count !== -1 && secInfoPageObj.count === secResLists.length) {
				this.isShowSecPageLoadedTxt = true; 
				return false;
			}
			return true;
		},
		async GetSecResLists() {
			if(!this.secPagingMoreFun()){
				return;
			}
			const result = await this.getSecList();
			if(!result) return;
			const { secResLists, count } = result;
			await this.secPagingListFun([...secResLists]);
			await this.secPagingCountFun(count);
			await this.secPagingAddFun();
			await this.secPagingMoreFun();
		},
	},

}